package com.zhangzhan.blog_api.controller;


import com.zhangzhan.base.common_model.result.ResponseResult;
import com.zhangzhan.blog_model.entity.Comment;
import com.zhangzhan.blog_model.vos.PageVo;
import com.zhangzhan.blog_service.service.CommentService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 评论表 前端控制器
 * </p>
 *
 * @author zhangzhan
 * @since 2024-02-05
 */
@RestController
@RequestMapping("/comment")
public class CommentController {

    @Autowired
    private CommentService commentService;

    @ApiOperation(value = "展示评论内容")
    @RequestMapping(value = "/commentList", method = RequestMethod.GET)
    public ResponseResult<List<PageVo>> commentList(@RequestParam("articleId") Long articleId,
                                                    @RequestParam("pageNum") Long pageNum,
                                                    @RequestParam("pageSize") Long pageSize) {
        return commentService.commentList(articleId, pageNum, pageSize);
    }

    @ApiOperation(value = "用户评论接口")
    @RequestMapping(value = "", method = RequestMethod.POST)
    public ResponseResult addComment(@RequestBody Comment comment) {
        return commentService.addComment(comment);
    }

}

